<template>
	<view class="cg-image" @click="$emit('click')">

		<u--image :showLoading="true" :shape="shape" :lazy-load="lazyLoad" :src="imageSrc" :width="width"
			:height="height" :mode="mode" :fade="fade" :radius="radius" :customStyle="customStyle">
		</u--image>
	</view>
</template>

<script>
	/**
	 * cg-image
	 * @description 全局通用image,防止图片地址变化
	 * @property {Boolean}			fade	是淡入淡出
	 * @example <cg-image width="88rpx" height="88rpx" src="" ></cg-image>
	 */
	import mixins from '@/store/$u.mixin.js';

	export default {
		name: "cg-image",
		mixins: [mixins],
		props: {
			src: {
				default: '',
				type: String
			},
			width: {
				default: '100%',
				type: String
			},
			customStyle: {
				default: '',
				type: String | Object
			},
			mode: {
				default: '',
				type: String
			},
			height: {
				default: '',
				type: String
			},
			// 可选值 square，circle
			shape: {
				default: 'square',
				type: String
			},
			lazyLoad: {
				default: true,
				type: Boolean
			},
			//  @property {Boolean}	fade 淡入淡出
			fade: {
				default: true,
				type: Boolean
			},
			/* nvue不可传入static，nvue不支持require引入 */
			type: {
				default: 'static',
				type: String
			},
			radius: {
				default: 0,
				type: Number | String
			}
		},
		computed: {
			imageSrc() {
				return this.getFilePath(this.src)
				// if (this.type === 'static') {
				// 	if (this.$config.useRemoteFile) {
				// 		return this.getFilePath(this.src)
				// 	} else {
				// 		return this.getStaticFilePath(this.src)
				// 	}
				// } else if (this.type === 'none') {
				// 	return this.src
				// } else {
				// 	return this.getFilePath(this.src)
				// }
			}
		},
		data() {
			return {

			};
		}
	}
</script>

<style lang="scss" scoped>
	.cg-image {
		// margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>